<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:80:"E:\phpstudy2016\WWW\shopsum\public/../application/admin\view\user\admin_set.html";i:1520944657;s:57:"E:\phpstudy2016\WWW\shopsum\application\public\admin.html";i:1520912952;}*/ ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>设置管理员权限-<?php echo \think\Config::get('title'); ?></title>
    <link rel="stylesheet" href="../../../../public/static/public/boo3/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css">
    <link rel="stylesheet" href="__PUBLIC__/index/css/sytle.css">
    <script src="__PUBLIC__/public/js/jquery-2.1.4.min.js"></script>
    <script src="__PUBLIC__/public/js/vue.min.js"></script>
    <script src="__PUBLIC__/public/js/jquery.transit.js"></script>
    <script src="__PUBLIC__/public/js/jquery.timers-1.2.js"></script>
    <script src="__PUBLIC__/public/layer-v3.1.1/layer/layer.js"></script>
    <style>
        #container{
            padding: 0 30px;
        }
        nav{
            background-color: #f5f5f5;
            padding: 10px 20px;
            z-index: 99;
            margin-bottom: 15px;
        }
        @media screen and (max-width: 800px) {
            nav{
                display: none;
            }
        }
    </style>
    <script>
        var DINDEX = '/admin/index';
        var DUSER = '/admin/user';
        var DADMIN = '/admin';
        var DJOURNALISM = '/admin/journalism';
        var DCOUNT = '/admin/count';
        //页面
        function yeMian(url,fn = 1,this_json = {title:'信息',area:['400px','450px']}) {

            var index = layer.open($.extend({type:2,content:url,end:function () {
                    if(typeof fn != 'number' ){
                        fn();
                    }
                }},this_json));
        }

        //看图
        function loock_img(url) {
            url = url.data('img');
            if((typeof url) != 'string'){
                layer.msg('没有数据查看',{icon:2});
                return;
            }
            layer.open({
                type:2,
                title:false,
                closeBtn:false,
                area:['100%','100%'],
                content:"<?php echo url('loock/index',['on'=>'true']); ?>?url="+url
            })
        }
    </script>
    
<link rel="stylesheet" href="__PUBLIC__/admin/css/user.admin_set.css">


</head>
<body>

<nav>
       <small><i class="fa fa-institution"></i></small> 首页 > <?php echo \think\Config::get('this_user_name'); if(\think\Request::instance()->param('on') == 'true'): ?>
       <a href="javascript:;" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name));"  title="关闭当前页面" class="btn btn-xs btn-default fa-pull-right " style="margin-left: 10px"><i class="fa fa-close"></i></a>
        <?php endif; ?>
    <a href="javascript:location.reload();" title="刷新" class="btn btn-xs btn-success fa-pull-right"><i class="fa fa-refresh"></i></a>
</nav>

<ul class="list-unstyled list-group" id="data">
    <template v-for="(key,index) in list">
        <li class="list-group-item navList" @click="nav(index)">
            <span class="">{{key[0].parentname}}</span>
            <span class="fa-pull-right"><i class="fa fa-angle-down"></i></span>
            <ul class="list-unstyled nei_rong" @click.stop="">
                <template v-for="(key2,index2) in list[index]">
                    <li>
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" @click.stop="one_cha(key2,$($event.target))" v-model="key2.state"> {{key2.navname}}
                            </label>
                        </div>
                    </li>
                </template>
            </ul>

        </li>
    </template>
</ul>



</body>
</html>

<script>
    var app = new Vue({
        el:'#data',
        data:{
            list:[],
            show:0,
            che:<?php echo $url; ?>
        }
    });
    /*点击展开内容*/
    app.nav = (i)=>{
        $('.navList').eq(i).find('.nei_rong').slideToggle();
    }

    //单选内容
    app.one_cha = (key,$this)=>{
        postData(key.navid,$this.is(':checked'));
    }
    get_data();
    //获取数据
    function get_data() {
        $.get(DINDEX+'/nav',function (da) {
            app.list = da;
            //添加选中状态
            $.each(app.list,function (i,n) {
                $.each(app.list[i],function (i2,n2) {
                    $.each(app.che,function (cheI,cheN) {
                        if(cheN.menu_id == n2.navid){
                            app.list[i][i2].state = true;
                            return false;
                        }
                        else {
                            app.list[i][i2].state = false;
                        }


                    })
                })
            })
        });
    }

    //发送数据 id1,id2,id3... $type=false:删除 true:添加
    function postData($id,$type=false) {
        var user = <?php echo $id; ?>;
        $type == false?$type = 0:$type=1;
       $.post(DUSER+'/admin_set',{id:$id,type:$type,user:user})
    }


</script>
